﻿<Window x:Class="Auremo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Auremo"
        xmlns:m="clr-namespace:Auremo.MusicLibrary"
        Title="Auremo MPD Client"
        Left="0" Top="0"
        MinWidth="960" MinHeight="590"
        Background="{StaticResource WindowBackgroundBrush}"
        Icon="../../Graphics/auremo.ico"
        PreviewKeyDown="OnKeyDown"
        Closing="OnExit"
        TextOptions.TextFormattingMode="Display">
    <Window.Resources>
        <l:IntToTimecodeConverter x:Key="IntToTimecodeConverter"/>
        <l:IntToBoolConverter x:Key="IntToBoolConverter"/>
        <l:NegateBoolConverter x:Key="NegateBoolConverter"/>
        <l:EqualsConverter x:Key="EqualsConverter"/>
        <l:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <l:BooleanAndConverter x:Key="BooleanAndConverter"/>
        <l:MultiBoolToVisibilityConverter x:Key="MultiBoolToVisibilityConverter"/>
    </Window.Resources>
    <Window.ToolTip>
        <ToolTip Name="m_MousePointerHint"
                 Background="{StaticResource ToolTipBackgroundBrush}"
                 BorderThickness="0"
                 Foreground="{StaticResource SelectedTextBrush}"
                 HasDropShadow="False"
                 IsHitTestVisible="False"
                 IsOpen="False"
                 Padding="10"
                 Visibility="Hidden"/>
    </Window.ToolTip>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Menu Style="{StaticResource MainMenuStyle}" Grid.ColumnSpan="2">
            <MenuItem Header="File">
                <MenuItem Header="Edit settings..." Click="OnEditSettingsClicked"/>
                <Separator/>
                <MenuItem Header="Add stream by URL..." Click="OnAddStreamURLClicked"/>
                <MenuItem Header="Add streams from PLS/M3U file..." Click="OnAddStreamsFromFileClicked"/>
                <Separator/>
                <MenuItem Header="Save current playlist into collection as..." Click="OnSavePlaylistAsClicked" IsEnabled="{Binding ElementName=m_PlaylistView, Path=Items.Count, Converter={StaticResource EqualsConverter}, Mode=OneWay}"/>
                <Separator/>
                <MenuItem Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                <Separator/>
                <MenuItem Header="Exit" Click="OnExitClicked"/>
            </MenuItem>
            <MenuItem Name="m_ConnectionMenuItem" Header="Connection">
                <MenuItem Header="Server" ItemsSource="{Binding Path=ServerList.Items}">
                    <MenuItem.ItemTemplate>
                        <DataTemplate>
                            <RadioButton GroupName="ServerRadioGroup" Content="{Binding Path=DisplayString}" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" Click="OnServerClicked" Checked="OnServerClicked"/>
                        </DataTemplate>
                    </MenuItem.ItemTemplate>
                </MenuItem>
                <MenuItem Header="Connect" Click="OnConnectClicked" IsEnabled="{Binding Path=ServerSession.IsConnected, Converter={StaticResource NegateBoolConverter}}"/>
                <MenuItem Header="Disconnect" Click="OnDisconnectClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                <MenuItem Header="Reset connection" Click="OnResetConnectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
            </MenuItem>
            <MenuItem Name="m_OutputsMenu" Header="Outputs" ItemsSource="{Binding Path=OutputCollection.Items}" IsEnabled="{Binding Path=OutputCollection.Items.Count,Converter={StaticResource IntToBoolConverter}}">
                <MenuItem.ItemTemplate>
                    <DataTemplate>
                        <CheckBox Content="{Binding Path=Name}" IsChecked="{Binding Path=IsEnabled, Mode=OneWay}" Click="OnEnableDisbaleOutput"/>
                    </DataTemplate>
                </MenuItem.ItemTemplate>
            </MenuItem>
            <MenuItem Name="m_ServerMenu" Header="Server" IsEnabled="{Binding Path=ServerSession.IsConnected}">
                <CheckBox Content="Single mode" IsChecked="{Binding Path=ServerStatus.IsOnSingle, Mode=OneWay}" Click="OnToggleSingleMode"/>
                <CheckBox Content="Consume mode" IsChecked="{Binding Path=ServerStatus.IsOnConsume, Mode=OneWay}" Click="OnToggleConsumeMode"/>
                <MenuItem Header="{Binding Path=ServerStatus.CrossfadeDisplayString}" Click="OnCrossfadeClick"/>
                <MenuItem Header="{Binding Path=ServerStatus.MixRampdbDisplayString}" Visibility="{Binding Path=ServerStatus.IsMixRampEnabled, Converter={StaticResource BoolToVisibilityConverter}}" Click="OnMixRampdbClick"/>
                <MenuItem Header="{Binding Path=ServerStatus.MixRampDelayDisplayString}" Click="OnMixRampDelayClick"/>
            </MenuItem>
            <MenuItem Header="Help">
                <MenuItem Header="View license (GPL2)..." Click="OnViewLicenseClicked"/>
                <MenuItem Header="About..." Click="OnAboutClicked"/>
                <Separator/>
                <Hyperlink NavigateUri="http://auremo.codeplex.com/" RequestNavigate="OnNavigate">Project home page</Hyperlink>
                <Hyperlink NavigateUri="http://auremo.codeplex.com/releases/" RequestNavigate="OnNavigate">Download page</Hyperlink>
                <Separator/>
                <MenuItem Header="Dump compact network log to file..." Click="OnDumpNetworkLogClicked"/>
                <MenuItem Name="m_VerboseNetworkLogMenuItem" Header="Dump verbose network log to file..." Click="OnDumpNetworkLogClicked"/>
            </MenuItem>
        </Menu>
        <Grid Grid.Row="1" Margin="0,10" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10*" MinWidth="210"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="10*" MinWidth="50"/>
            </Grid.ColumnDefinitions>
            <Image Source="Graphics/Auremo_icon.png" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="3" Margin="32"/>
            <TabControl Name="m_CollectionBrowsingModes" Style="{StaticResource MusicCollectionTabControlStyle}" Focusable="False" KeyboardNavigation.DirectionalNavigation="None">
                <TabItem Name="m_QuickSearchTab" Header="Quick search">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <DataGrid Name="m_QuickSearchResultsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  ItemsSource="{Binding Path=QuickSearch.SearchResults}"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  TextInput="OnCollectionTextInput"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Title" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Title}"/>
                                <DataGridTextColumn Header="Artist" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Artist}"/>
                                <DataGridTextColumn Header="Album" MinWidth="60" Width="*" Binding="{Binding Path=Item.Album}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_QuickSearchResultsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding ElementName=m_QuickSearchResultsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding ElementName=m_QuickSearchResultsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding ElementName=m_QuickSearchResultsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_SearchResultsHint" Grid.Row="0" Style="{StaticResource CollectionHintTextStyle}" Text="No search results." IsEnabled="{Binding Path=QuickSearch.SearchResults.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <TextBox Name="m_QuickSearchBox" Style="{StaticResource TextBoxStyle}" Grid.Row="1" Margin="0,10,0,0" Height="28" FontSize="15" VerticalContentAlignment="Center"
                                 Text="{Binding Path=QuickSearch.SearchString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <TextBox.IsEnabled>
                                <MultiBinding Converter="{StaticResource BooleanAndConverter}">
                                    <Binding ElementName="m_QuickSearchTab" Path="IsSelected"/>
                                    <Binding Path="ServerSession.IsConnected"/>
                                </MultiBinding>
                            </TextBox.IsEnabled>
                        </TextBox>
                        <TextBlock Name="m_SearchBoxHint" Style="{StaticResource TextBoxHintTextStyle}" Grid.Row="1" Margin="10,6,0,0" Text="Type here to start searching." IsEnabled="{Binding Path=QuickSearch.SearchString.Length, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" FontSize="16"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_AdvancedSearchTab" Header="Advanced search">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <DataGrid Name="m_AdvancedSearchResultsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  Grid.ColumnSpan="2"
                                  ItemsSource="{Binding Path=AdvancedSearch.SearchResults}"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Title" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Title}"/>
                                <DataGridTextColumn Header="Artist" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Artist}"/>
                                <DataGridTextColumn Header="Album" MinWidth="60" Width="*" Binding="{Binding Path=Item.Album}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_AdvancedSearchResultsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding ElementName=m_AdvancedSearchResultsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding ElementName=m_AdvancedSearchResultsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding ElementName=m_AdvancedSearchResultsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Grid.Row="0" Style="{StaticResource CollectionHintTextStyle}" Text="No search results." IsEnabled="{Binding Path=AdvancedSearch.SearchResults.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <TextBox Name="m_AdvancedSearchBox" Style="{StaticResource TextBoxStyle}" Grid.Row="2" Height="28" Margin="0,10,0,0"
                                 FontSize="15" VerticalContentAlignment="Center"
                                 Text="{Binding Path=AdvancedSearch.SearchString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <TextBox.IsEnabled>
                                <MultiBinding Converter="{StaticResource BooleanAndConverter}">
                                    <Binding ElementName="m_AdvancedSearchTab" Path="IsSelected"/>
                                    <Binding Path="ServerSession.IsConnected"/>
                                </MultiBinding>
                            </TextBox.IsEnabled>
                        </TextBox>
                        <TextBlock Style="{StaticResource TextBoxHintTextStyle}" Grid.Row="2" Margin="10,6,0,0" Text="Type search terms here." IsEnabled="{Binding ElementName=m_AdvancedSearchBox, Path=Text.Length, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" FontSize="16"/>
                        <Button Name="m_AdvancedSearchButton"
                                Style="{StaticResource SearchButtonStyle}"
                                Grid.Row="2" Grid.Column="1"
                                IsDefault="True"
                                Width="28" Height="28" Margin="5,10,0,0"
                                Click="OnAdvancedSearchClicked">
                            <Button.IsEnabled>
                                <MultiBinding Converter="{StaticResource BooleanAndConverter}">
                                    <Binding ElementName="m_AdvancedSearchBox" Path="Text.Length" Converter="{StaticResource IntToBoolConverter}"/>
                                    <Binding Path="ServerSession.IsConnected"/>
                                </MultiBinding>
                            </Button.IsEnabled>
                            <Grid>
                                <Path Style="{StaticResource ButtonGlyphStyle}" Data="M 6,13 0,19 2,21 8,15 6,13"/>
                                <Path Style="{StaticResource ButtonGlyphStyle}">
                                    <Path.Data>
                                        <CombinedGeometry GeometryCombineMode="Xor">
                                            <CombinedGeometry.Geometry1>
                                                <EllipseGeometry RadiusX="8" RadiusY="8" Center="13,8"/>
                                            </CombinedGeometry.Geometry1>
                                            <CombinedGeometry.Geometry2>
                                                <EllipseGeometry RadiusX="6" RadiusY="6" Center="13,8"/>
                                            </CombinedGeometry.Geometry2>
                                        </CombinedGeometry>
                                    </Path.Data>
                                </Path>
                            </Grid>
                        </Button>
                        <Border Grid.Row="1" Grid.ColumnSpan="2" Margin="0,10,0,0" BorderThickness="1" BorderBrush="{StaticResource PassiveGenericBorderBrush}" Background="{StaticResource ListBackgroundBrush}">
                            <StackPanel Orientation="Vertical">
                                <StackPanel Orientation="Horizontal" Margin="2,2,0,0">
                                    <CheckBox Content="Local" IsChecked="{Binding Path=AdvancedSearch.IncludeLocal, Mode=TwoWay}" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                    <CheckBox Content="Spotify" IsChecked="{Binding Path=AdvancedSearch.IncludeSpotify, Mode=TwoWay}" IsEnabled="{Binding Path=ServerSession.IsConnected}" Margin="14,0"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="2,2,0,2">
                                    <RadioButton Content="Any" IsChecked="{Binding Path=AdvancedSearch.SearchByAny, Mode=TwoWay}" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                    <RadioButton Content="Artist" IsChecked="{Binding Path=AdvancedSearch.SearchByArtist, Mode=TwoWay}" IsEnabled="{Binding Path=ServerSession.IsConnected}" Margin="14,0,0,0"/>
                                    <RadioButton Content="Album" IsChecked="{Binding Path=AdvancedSearch.SearchByAlbum, Mode=TwoWay}" IsEnabled="{Binding Path=ServerSession.IsConnected}" Margin="14,0,0,0"/>
                                    <RadioButton Content="Title" IsChecked="{Binding Path=AdvancedSearch.SearchByTitle, Mode=TwoWay}" IsEnabled="{Binding Path=ServerSession.IsConnected}" Margin="14,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                        </Border>
                    </Grid>
                </TabItem>
                <TabItem Name="m_ArtistListTab" Header="Artist list">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <DataGrid Name="m_ArtistsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  ItemsSource="{Binding Path=DatabaseView.Artists}"
                                  SelectionChanged="OnSelectedArtistsChanged"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Artist" Width="*" Binding="{Binding Path=Item}" CanUserResize="True"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_ArtistsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.SelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.SelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.SelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_ArtistsViewRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_ArtistsHint" Style="{StaticResource CollectionHintTextStyle}" Text="No artists available." IsEnabled="{Binding ElementName=m_ArtistsView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <DataGrid Name="m_AlbumsBySelectedArtistsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  Grid.Row="1"
                                  Margin="0,-1,0,0"
                                  ItemsSource="{Binding Path=DatabaseView.AlbumsBySelectedArtists}"
                                  SelectionChanged="OnSelectedAlbumsBySelectedArtistsChanged"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Title" Width="*" Binding="{Binding Path=Item.Title}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_AlbumsBySelectedArtistsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.SelectedAlbumsBySelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.SelectedAlbumsBySelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.SelectedAlbumsBySelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_AlbumsBySelectedArtistsViewRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_AlbumsBySelectedArtistsHint" Grid.Row="1" Style="{StaticResource CollectionHintTextStyle}" Text="Select artists to see albums by them." IsEnabled="{Binding ElementName=m_AlbumsBySelectedArtistsView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <DataGrid Name="m_SongsOnSelectedAlbumsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  Grid.Row="2"
                                  Margin="0,-1,0,0"
                                  ItemsSource="{Binding Path=DatabaseView.SongsOnSelectedAlbumsBySelectedArtists}"
                                  SelectionChanged="OnSelectedSongsOnSelectedAlbumsBySelectedArtistsChanged"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Track#" MinWidth="60" Width="Auto" Binding="{Binding Item.Track}"/>
                                <DataGridTextColumn Header="Title" MinWidth="60" Width="*" Binding="{Binding Item.DisplayString}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_SongsOnSelectedAlbumsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.SelectedSongsOnSelectedAlbumsBySelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.SelectedSongsOnSelectedAlbumsBySelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.SelectedSongsOnSelectedAlbumsBySelectedArtists.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_SongsOnSelectedAlbumsViewRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_SongsOnSelectedAlbumsHint" Grid.Row="2" Style="{StaticResource CollectionHintTextStyle}" Text="Select albums to view songs on them." IsEnabled="{Binding ElementName=m_SongsOnSelectedAlbumsView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_ArtistTreeTab" Header="Artist tree">
                    <Grid>
                        <TreeView Name="m_ArtistTree"
                                  ItemsSource="{Binding Path=DatabaseView.ArtistTree}"
                                  Style="{StaticResource MusicCollectionTreeViewStyle}"
                                  PreviewKeyDown="OnTreeViewKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnTreeViewMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnTreeViewMouseUp"
                                  SelectedItemChanged="OnTreeViewSelectionChanged">
                            <TreeView.Resources>
                                <HierarchicalDataTemplate DataType="{x:Type m:HierarchicalLibraryItem}" ItemsSource="{Binding Path=Children}">
                                    <TextBlock Text="{Binding DisplayString}"/>
                                </HierarchicalDataTemplate>
                            </TreeView.Resources>
                            <TreeView.ContextMenu>
                                <ContextMenu Name="m_ArtistTreeContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.ArtistTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.ArtistTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.ArtistTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_ArtistTreeRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </TreeView.ContextMenu>
                        </TreeView>
                        <TextBlock Name="m_ArtistsTreeHint" Style="{StaticResource CollectionHintTextStyle}" Text="Music collection is not available." IsEnabled="{Binding ElementName=m_ArtistTree, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_GenreListTab" Header="Genre list">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <DataGrid Name="m_GenresView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  ItemsSource="{Binding Path=DatabaseView.Genres}"
                                  SelectionChanged="OnSelectedGenresChanged"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Genre" Width="*" Binding="{Binding Path=Item}" CanUserResize="True"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_GenresViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.SelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.SelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.SelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_GenresViewRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_GenresHint" Style="{StaticResource CollectionHintTextStyle}" Text="No genres available." IsEnabled="{Binding ElementName=m_GenresView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <DataGrid Name="m_AlbumsOfSelectedGenresView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  Margin="0,-1,0,0"
                                  Grid.Row="1"
                                  ItemsSource="{Binding Path=DatabaseView.AlbumsOfSelectedGenres}"
                                  SelectionChanged="OnSelectedAlbumsOfSelectedGenresChanged"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Artist" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Artist}"/>
                                <DataGridTextColumn Header="Album" MinWidth="60" Width="*" Binding="{Binding Path=Item.Title}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_AlbumsOfSelectedGenresViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.SelectedAlbumsOfSelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.SelectedAlbumsOfSelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.SelectedAlbumsOfSelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_AlbumsOfSelectedGenresViewRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_AlbumsOfSelectedGenresHint" Grid.Row="1" Style="{StaticResource CollectionHintTextStyle}" Text="Select genres to see albums belonging to them." IsEnabled="{Binding ElementName=m_AlbumsOfSelectedGenresView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <DataGrid Name="m_SongsOnSelectedGenreAlbumsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  Margin="0,-1,0,0"
                                  Grid.Row="2"
                                  ItemsSource="{Binding Path=DatabaseView.SongsOnSelectedAlbumsOfSelectedGenres}"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Track#" MinWidth="60" Width="Auto" Binding="{Binding Item.Track}"/>
                                <DataGridTextColumn Header="Title" MinWidth="60" Width="*" Binding="{Binding Item.DisplayString}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_SongsOnSelectedGenreAlbumsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.SelectedSongsOnSelectedAlbumsOfSelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.SelectedSongsOnSelectedAlbumsOfSelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.SelectedSongsOnSelectedAlbumsOfSelectedGenres.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_SongsOnSelectedGenreAlbumsHint" Grid.Row="2" Style="{StaticResource CollectionHintTextStyle}" Text="Select albums to view songs on them." IsEnabled="{Binding ElementName=m_SongsOnSelectedGenreAlbumsView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_GenreTreeTab" Header="Genre tree">
                    <Grid>
                        <TreeView Name="m_GenreTree"
                                  ItemsSource="{Binding Path=DatabaseView.GenreTree}"
                                  Style="{StaticResource MusicCollectionTreeViewStyle}"
                                  PreviewKeyDown="OnTreeViewKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnTreeViewMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnTreeViewMouseUp"
                                  SelectedItemChanged="OnTreeViewSelectionChanged">
                            <TreeView.Resources>
                                <HierarchicalDataTemplate DataType="{x:Type m:HierarchicalLibraryItem}" ItemsSource="{Binding Path=Children}">
                                    <TextBlock Text="{Binding DisplayString}"/>
                                </HierarchicalDataTemplate>
                            </TreeView.Resources>
                            <TreeView.ContextMenu>
                                <ContextMenu Name="m_GenreTreeContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.GenreTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.GenreTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.GenreTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_GenreTreeRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </TreeView.ContextMenu>
                        </TreeView>
                        <TextBlock Name="m_GenresTreeHint" Style="{StaticResource CollectionHintTextStyle}" Text="Music collection is not available." IsEnabled="{Binding ElementName=m_GenreTree, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_FilesystemTab" Header="Filesystem">
                    <Grid>
                        <TreeView Name="m_DirectoryTree"
                                  ItemsSource="{Binding Path=DatabaseView.DirectoryTree}"
                                  Style="{StaticResource MusicCollectionTreeViewStyle}"
                                  PreviewKeyDown="OnTreeViewKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnTreeViewMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnTreeViewMouseUp"
                                  SelectedItemChanged="OnTreeViewSelectionChanged">
                            <TreeView.Resources>
                                <HierarchicalDataTemplate DataType="{x:Type m:HierarchicalLibraryItem}" ItemsSource="{Binding Path=Children}">
                                    <TextBlock Text="{Binding Item.FilesystemDisplayString}"/>
                                </HierarchicalDataTemplate>
                            </TreeView.Resources>
                            <TreeView.ContextMenu>
                                <ContextMenu Name="m_DirectoryTreeContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=DatabaseView.DirectoryTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=DatabaseView.DirectoryTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=DatabaseView.DirectoryTreeController.MultiSelection.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Name="m_DirectoryTreeRescanMusicCollectionContextMenuItem" Header="Rescan music collection" Click="OnRescanMusicCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </TreeView.ContextMenu>
                        </TreeView>
                        <TextBlock Name="m_DirectoryTreeHint" Style="{StaticResource CollectionHintTextStyle}" Text="Music collection is not available." IsEnabled="{Binding ElementName=m_DirectoryTree, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_StreamsTab" Header="Streams">
                    <Grid>
                        <DataGrid Name="m_StreamsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  ItemsSource="{Binding Path=StreamsCollection.Streams}"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Stream" Width="*" Binding="{Binding}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_StreamsViewContextMenu">
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding ElementName=m_StreamsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding ElementName=m_StreamsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding ElementName=m_StreamsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Header="Rename stream..." Click="OnRenameSelectedStreamClicked" IsEnabled="{Binding ElementName=m_StreamsView, Path=SelectedItems.Count, Converter={StaticResource EqualsConverter}, Mode=OneWay, ConverterParameter=1}"/>
                                    <MenuItem Header="Delete streams" Click="OnDeleteSelectedStreamsClicked" IsEnabled="{Binding ElementName=m_StreamsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Header="Add stream by URL..." Click="OnAddStreamURLClicked"/>
                                    <MenuItem Header="Add streams from PLS/M3U file..." Click="OnAddStreamsFromFileClicked"/>
                                    <Separator/>
                                    <MenuItem Header="Save selection to file..." Click="OnSaveSelectedStreamsToFileClicked" IsEnabled="{Binding ElementName=m_StreamsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_StreamsHint" Style="{StaticResource CollectionHintTextStyle}" Text="Right-click here to add streams." IsEnabled="{Binding ElementName=m_StreamsView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
                <TabItem Name="m_PlaylistsTab" Header="Playlists">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <DataGrid Name="m_SavedPlaylistsView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  SelectionMode="Single"
                                  ItemsSource="{Binding Path=SavedPlaylists.Items}"
                                  SelectionChanged="OnSelectedSavedPlaylistChanged"
                                  PreviewKeyDown="OnSavedPlaylistsViewKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnSavedPlaylistsViewDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Playlist" Width="*" Binding="{Binding Path=Item.Title}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu Name="m_SavedPlaylistsViewContextMenu">
                                    <MenuItem Header="Send to playlist" Click="OnSendSavedPlaylistToPlaylistClicked" IsEnabled="{Binding ElementName=m_SavedPlaylistsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Rename..." Click="OnRenameSavedPlaylistClicked" IsEnabled="{Binding ElementName=m_SavedPlaylistsView, Path=SelectedItems.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=1, Mode=OneWay}"/>
                                    <MenuItem Header="Delete" Click="OnDeleteSavedPlaylistClicked" IsEnabled="{Binding ElementName=m_SavedPlaylistsView, Path=SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <Separator/>
                                    <MenuItem Header="Rescan playlists collection" Click="OnRescanPlaylistsCollectionClicked" IsEnabled="{Binding Path=ServerSession.IsConnected}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_SavedPlaylistsHint" Style="{StaticResource CollectionHintTextStyle}" Text="No saved playlists." IsEnabled="{Binding ElementName=m_SavedPlaylistsView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                        <DataGrid Name="m_ItemsOnSelectedSavedPlaylistView"
                                  Style="{StaticResource MusicCollectionDataGridStyle}"
                                  Grid.Row="1"
                                  Margin="0,-1,0,0"
                                  ItemsSource="{Binding Path=SavedPlaylists.ItemsOnSelectedPlaylist}"
                                  PreviewKeyDown="OnMusicCollectionDataGridKeyDown"
                                  TextInput="OnCollectionTextInput"
                                  PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                                  MouseMove="OnMouseMoveDragDrop"
                                  MouseLeftButtonUp="OnDataGridRowMouseUp"
                                  MouseDoubleClick="OnMusicCollectionDataGridDoubleClicked">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Title" Width="*" Binding="{Binding Path=Item.Title}"/>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Add to playlist as last" Click="OnAddToPlaylistAsLastClicked" IsEnabled="{Binding Path=SavedPlaylists.SelectedItemsOnSelectedPlaylist.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Add to playlist as next" Click="OnAddToPlaylistAsNextClicked" IsEnabled="{Binding Path=SavedPlaylists.SelectedItemsOnSelectedPlaylist.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                    <MenuItem Header="Play this" Click="OnPlayThisClicked" IsEnabled="{Binding Path=SavedPlaylists.SelectedItemsOnSelectedPlaylist.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                        <TextBlock Name="m_SavedPlaylistItemsHint" Style="{StaticResource CollectionHintTextStyle}" Text="Select a playlist to see the items on it." Grid.Row="1" IsEnabled="{Binding ElementName=m_SavedPlaylistsView, Path=SelectedItems.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
                    </Grid>
                </TabItem>
            </TabControl>
            <GridSplitter HorizontalAlignment="Left" Width="10" VerticalAlignment="Stretch" Grid.Column="1" ResizeBehavior="PreviousAndNext" Height="Auto" Background="Transparent" Margin="0,0,0,5" IsEnabled="True" ResizeDirection="Columns" Cursor="SizeWE"/>
            <DataGrid Name="m_PlaylistView"
                      Style="{StaticResource PlaylistStyle}"
                      ItemsSource="{Binding Path=Playlist.Items}"
                      SelectionChanged="OnSelectedPlaylistItemsChanged"
                      AllowDrop="True"
                      PreviewKeyDown="OnPlaylistViewKeyDown"
                      TextInput="OnCollectionTextInput"
                      PreviewMouseLeftButtonDown="OnDataGridRowMouseDown"
                      MouseMove="OnMouseMoveDragDrop"
                      MouseLeftButtonUp="OnDataGridRowMouseUp"
                      MouseDoubleClick="OnPlaylistViewDoubleClicked"
                      DragOver="OnPlaylistViewDragOver"
                      DragLeave="OnPlaylistViewDragLeave"
                      Drop="OnPlaylistViewDrop"
                      Grid.Column="2">
                <DataGrid.Columns>
                    <DataGridTemplateColumn Width="15" CanUserResize="False">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Path x:Name="StatusIcon" Data="M 0,0" StrokeThickness="0" Fill="Transparent" Stretch="None"/>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Path=Item.IsPlaying}" Value="True">
                                        <Setter TargetName="StatusIcon" Property="Fill" Value="{StaticResource PlayingTextBrush}"/>
                                        <Setter TargetName="StatusIcon" Property="Data" Value="M 0,3 8,8.5 0,14"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=Item.IsPaused}" Value="True">
                                        <Setter TargetName="StatusIcon" Property="Fill" Value="{StaticResource PlayingTextBrush}"/>
                                        <Setter TargetName="StatusIcon" Property="Data" Value="M 0,3 3,3 3,14 0,14 M 5,3 8,3 8,14 5,14"/>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Title" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Title}"/>
                    <DataGridTextColumn Header="Artist" MinWidth="60" Width="Auto" Binding="{Binding Path=Item.Artist}"/>
                    <DataGridTextColumn Header="Album" MinWidth="60" Width="*" Binding="{Binding Path=Item.Album}"/>
                </DataGrid.Columns>
                <DataGrid.ContextMenu>
                    <ContextMenu Name="m_PlaylistViewContextMenu">
                        <MenuItem Header="Clear" Click="OnClearPlaylistViewClicked" IsEnabled="{Binding Path=Playlist.Items.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                        <MenuItem Header="Remove selected items" Click="OnRemoveSelectedPlaylistItemsClicked" IsEnabled="{Binding Path=Playlist.SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                        <MenuItem Header="Remove everything but selected items" Click="OnCropToSelectedPlaylistItemsClicked" IsEnabled="{Binding Path=Playlist.SelectedItems.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                        <MenuItem Header="Remove duplicate items" Click="OnDedupPlaylistViewClicked" IsEnabled="{Binding Path=Playlist.Items.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                        <MenuItem Header="Shuffle" Click="OnShufflePlaylistClicked" IsEnabled="{Binding Path=Playlist.Items.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                        <Separator/>
                        <MenuItem Name="ShowInArtistListMenuItem" Header="Show in Artist list" IsEnabled="{Binding Path=Playlist.NumberOfSelectedLocalSongs, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" Visibility="{Binding ElementName=m_ArtistListTab,Path=IsVisible,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}" Click="OnShowInArtistsListClicked"/>
                        <MenuItem Name="ShowInArtistTreeMenuItem" Header="Show in Artist tree" IsEnabled="{Binding Path=Playlist.NumberOfSelectedLocalSongs, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" Visibility="{Binding ElementName=m_ArtistTreeTab,Path=IsVisible,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}" Click="OnShowInArtistsTreeClicked"/>
                        <MenuItem Name="ShowInGenreListMenuItem" Header="Show in Genre list" IsEnabled="{Binding Path=Playlist.NumberOfSelectedLocalSongs, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" Visibility="{Binding ElementName=m_GenreListTab,Path=IsVisible,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}" Click="OnShowInGenreListClicked"/>
                        <MenuItem Name="ShowInGenreTreeMenuItem" Header="Show in Genre tree" IsEnabled="{Binding Path=Playlist.NumberOfSelectedLocalSongs, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" Visibility="{Binding ElementName=m_GenreTreeTab,Path=IsVisible,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}" Click="OnShowInGenreTreeClicked"/>
                        <MenuItem Name="ShowInFilesystemMenuItem" Header="Show in Filesystem" IsEnabled="{Binding Path=Playlist.NumberOfSelectedLocalSongs, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" Visibility="{Binding ElementName=m_FilesystemTab,Path=IsVisible,Mode=OneWay,Converter={StaticResource BoolToVisibilityConverter}}" Click="OnShowInFilesystemTreeClicked"/>
                        <Separator>
                            <Separator.Visibility>
                                <MultiBinding Converter="{StaticResource MultiBoolToVisibilityConverter}">
                                    <Binding ElementName="ShowInArtistListMenuItem" Path="IsVisible"/>
                                    <Binding ElementName="ShowInArtistTreeMenuItem" Path="IsVisible"/>
                                    <Binding ElementName="ShowInGenreListMenuItem" Path="IsVisible"/>
                                    <Binding ElementName="ShowInGenreTreeMenuItem" Path="IsVisible"/>
                                    <Binding ElementName="ShowInFilesystemMenuItem" Path="IsVisible"/>
                                </MultiBinding>
                            </Separator.Visibility>
                        </Separator>
                        <MenuItem Header="Save playlist into collection as..." Click="OnSavePlaylistAsClicked" IsEnabled="{Binding Path=Playlist.Items.Count, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}"/>
                    </ContextMenu>
                </DataGrid.ContextMenu>
            </DataGrid>
            <TextBlock Name="m_PlaylistViewHint" Grid.Column="3" Style="{StaticResource CollectionHintTextStyle}" Text="Drag music here to add it to the playlist." IsEnabled="{Binding ElementName=m_PlaylistView, Path=Items.Count, Converter={StaticResource EqualsConverter}, ConverterParameter=0, Mode=OneWay}"/>
            <Line Name="m_DropPositionIndicator" Grid.Column="3" X1="0" X2="464" Y1="80" Y2="80" IsHitTestVisible="False" Visibility="Hidden" StrokeThickness="1" Stroke="{StaticResource DropPositionIndicatorBrush}"/>
        </Grid>
        <Border Grid.Row="2" Padding="20,4" BorderBrush="{StaticResource HeaderBorderBrush}" BorderThickness="0,1,0,0" Background="{StaticResource ControlPanelBackgroundBrush}">
            <DockPanel LastChildFill="True" Margin="0,5,0,0">
                <Label Name="m_PlayPosition" DockPanel.Dock="Left" VerticalAlignment="Center" Width="40" FontSize="9" Foreground="{StaticResource ButtonActiveGlyphGlowBrush}" Content="{Binding Path=MainWindow.PlayPosition, Converter={StaticResource IntToTimecodeConverter}}"/>
                <Label Name="m_SongLength" DockPanel.Dock="Right" VerticalAlignment="Center" Width="40" FontSize="9" Foreground="{StaticResource ButtonActiveGlyphGlowBrush}" Content="{Binding Path=ServerStatus.SongLength, Converter={StaticResource IntToTimecodeConverter}}"/>
                <Slider Name="m_SeekBar" Style="{StaticResource MusicSliderStyle}" Value="{Binding Path=MainWindow.PlayPosition, Mode=OneWay}" Maximum="{Binding Path=ServerStatus.SongLength}" IsEnabled="{Binding Path=ServerStatus.SongLength, Converter={StaticResource IntToBoolConverter}, Mode=OneWay}" Margin="2" VerticalAlignment="Center"
                        PreviewMouseDown="OnSeekBarDragStart" ValueChanged="OnSeekBarValueChanged" PreviewMouseUp="OnSeekBarDragEnd" MouseWheel="OnSeekBarMouseWheel"/>
            </DockPanel>
        </Border>
        <Border Grid.Row="3" Padding="20,5" BorderBrush="{StaticResource SeparatorBorderBrush}" BorderThickness="0,1" Background="{StaticResource ControlPanelBackgroundBrushBelow}">
            <Grid Name="m_PlaybackControlPanel" Grid.Row="3" Height="55">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Name="m_BackButton" Style="{StaticResource PlaybackButtonStyle}" Click="OnBackButtonClicked">
                        <Path Style="{StaticResource ButtonGlyphStyle}" Data="M 0,0 1,0 1,4 2,4 6,0 6,4 7,4 11,0 11,9 7,5 6,5 6,9 2,5 1,5 1,9 0,9"/>
                    </Button>
                    <l:StickyButton x:Name="m_PlayButton" Style="{StaticResource PlaybackStickyButtonStyle}" IsDown="{Binding Path=ServerStatus.IsPlaying}" Click="OnPlayButtonClicked">
                        <Path Style="{StaticResource StickyButtonGlyphStyle}" Data="M 0,0 7,5 0,10"/>
                    </l:StickyButton>
                    <l:StickyButton x:Name="m_PauseButton" Style="{StaticResource PlaybackStickyButtonStyle}" IsDown="{Binding Path=ServerStatus.IsPaused}" Click="OnPauseButtonClicked">
                        <Path Style="{StaticResource StickyButtonGlyphStyle}" Data="M 0,0 3,0 3,9 0,9 M 5,0 8,0 8,9 5,9" />
                    </l:StickyButton>
                    <l:StickyButton x:Name="m_StopButton" Style="{StaticResource PlaybackStickyButtonStyle}" IsDown="{Binding Path=ServerStatus.IsStopped}" Click="OnStopButtonClicked">
                        <Path Style="{StaticResource StickyButtonGlyphStyle}" Data="M 0,0 6,0 6,7 0,7"/>
                    </l:StickyButton>
                    <Button Name="m_SkipButton" Style="{StaticResource PlaybackButtonStyle}" Click="OnSkipButtonClicked">
                        <Path Style="{StaticResource ButtonGlyphStyle}" Data="M 0,0 4,4 5,4 5,0 9,4 10,4 10,0 11,0 11,9 10,9 10,5 9,5 5,9 5,5 4,5 0,9"/>
                    </Button>
                </StackPanel>
                <Slider Name="m_VolumeControl" Style="{StaticResource MusicSliderStyle}" Value="{Binding Path=MainWindow.Volume, Mode=OneWay}" IsEnabled="{Binding Path=MainWindow.VolumeControlIsEnabled}" Grid.Column="1" Width="200" Minimum="0" Maximum="100" TickFrequency="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="10,0"
                        PreviewMouseDown="OnVolumeControlDragStart" ValueChanged="OnVolumeControlValueChanged" PreviewMouseUp="OnVolumeControlDragEnd" MouseWheel="OnVolumeMouseWheel"/>
                <StackPanel Grid.Column="2" Orientation="Horizontal">
                    <l:StickyButton x:Name="m_RepeatButton" Style="{StaticResource PlaybackStickyButtonStyle}" IsDown="{Binding Path=ServerStatus.IsOnRepeat}" Click="OnToggleRepeatClicked">
                        <Path Style="{StaticResource ButtonGlyphStyle}" Data="M 8,12 11,9 11,15 M 11,13 Q 17,13 17,9 L 17,6 Q 17,0 10,0 L 7,0 Q 0,0 0,6 L 0,9 Q 0,13 6,13 L 6,11 Q 2,11 2,9 L 2,6 Q 2,2 7,2 L 10,2 Q 15,2 15,6 L 15,9 Q 15,11 11,11"/>
                    </l:StickyButton>
                    <l:StickyButton x:Name="m_RandomButton" Style="{StaticResource PlaybackStickyButtonStyle}" IsDown="{Binding Path=ServerStatus.IsOnRandom}" Click="OnToggleRandomClicked">
                        <Grid>
                            <Path Style="{StaticResource ButtonGlyphStyle}" Data="M 17,3 14,0 14,6 M 14,2 C 10,2 9,9 4,11 L 0,11 0,13 3,13 C 8,13 11,4 14,4"/>
                            <Path Style="{StaticResource ButtonGlyphStyle}" Data="M 17,12 14,15 14,9 M 14,13 C 10,13 9,6 4,4 L 0,4 0,2 3,2 C 8,2 11,11 14,11"/>
                        </Grid>
                    </l:StickyButton>
                </StackPanel>
            </Grid>
        </Border>
        <Border Grid.Row="4" BorderBrush="{StaticResource SeparatorBorderBrush}" BorderThickness="0,1,0,0">
            <StatusBar Padding="5,0" Background="{StaticResource WindowBackgroundBrush}" Height="30">
                <StatusBarItem HorizontalAlignment="Left">
                    <TextBox Style="{StaticResource CopyableTextBlockStyle}" Text="{Binding Path=CurrentSong.DisplayString, Mode=OneWay}"/>
                </StatusBarItem>
                <StatusBarItem HorizontalAlignment="Right">
                    <TextBox Style="{StaticResource CopyableTextBlockStyle}" Text="{Binding Path=ServerSession.StatusMessage, Mode=OneWay}" HorizontalAlignment="Right" VerticalAlignment="Top"/>
                </StatusBarItem>
            </StatusBar>
        </Border>
        <l:MainWindowOverlay x:Name="m_Overlay" Grid.ColumnSpan="2" Grid.RowSpan="5" Visibility="Collapsed"/>
    </Grid>
</Window>
